package log;

import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;

public class MyLogger {

	private Logger logger;
	public MyLogger(){
		 logger = Logger.getLogger("MyLog");
		 
		 FileHandler fh;

		    try {

		    	
		    	
		      // This block configure the logger with handler and formatter
		      fh = new FileHandler(System.getProperty("user.dir") +"\\MyLogFile.log", true);
		      logger.addHandler(fh);
		      logger.setLevel(Level.ALL);
		      SimpleFormatter formatter = new SimpleFormatter();
		      fh.setFormatter(formatter);
		    } catch (SecurityException e) {
			      e.printStackTrace();
			    } catch (IOException e) {
			      e.printStackTrace();
			    }
		    
	}
	  public void log(Level level,String textLog) {
	      logger.log(level,textLog);	  
	  }

	}

